# MP
include Makefile.config
SRCS= $(wildcard *.cpp)
LIBNAME= RobotSim
INCDIR=
DEFINES += $(MATH_DEFINES)

STD_INCLUDES= /usr/include/
STD_LIBS=
PY_INCLUDES= /usr/include/python2.6/
PY_LIBDIR= /usr/lib/
#PY_INCLUDES= /l/python2.7/include/python2.7/
#PY_LIBDIR= /l/python2.7/lib/

INCDIR = . $(PY_INCLUDES) $(INCDIRS)

#ODE_INSTALL_DIR = /usr/local/
ODE_INSTALL_DIR = $(CURDIR)/ode-0.11.1

CPPFLAGS = -Wall -fPIC

include Makefile.template

# SO_FLAGS = -dynamiclib
SO_FLAGS = -shared

#PY_LIB = python
PY_LIB = python2.6.dll

LIB = $(PY_LIB) $(LIBS)
LIBDIR = $(PY_LIBDIR) $(LIBDIRS) ode-0.11.1/ode/src
SUBDIRS = Main Modeling Simulation Xml View
SUBOBJS =  $(foreach d,$(SUBDIRS) ,$(wildcard $(d)/$(OBJDIR)/*))

.PHONY: clean lib $(SUBDIRS) tinyxml ode KrisLibrary

default: lib
	@echo Done.

#dependencies
deps: tinyxml ode KrisLibrary
	#;

KrisLibrary:
	cd $(KRISLIB); make all

tinyxml:
	cd $(TINYXML); make; $(AR) rcs libtinyxml.a *.o

ode:
	cd $(ODE); ./configure --with-trimesh=gimpact --disable-demos; make 


#subdirectories
Main: 
	cd Main; make

Modeling:
	cd Modeling; make

Simulation:
	cd Simulation; make

Xml:
	cd Xml; make

View:
	cd View; make

clean:
	-cd Main; make clean
	-rm _robotsim.so
	-cd Modeling; make clean
	-cd Simulation; make clean
	-cd Xml; make clean
	-cd View; make clean

docs:
	cd Main; make docs
	pydoc -w robotsim

lib:
	python setup.py build_ext --inplace

#manual development
lib_dev: $(SUBDIRS)
	cp Main/robotsim.py .
	g++ -Wall -fPIC $(SO_FLAGS) $(SUBOBJS) $(addprefix -L,$(LIBDIR)) $(addprefix -l,$(LIB)) -o _robotsim.so

cygwin: lib_dev
	cp _robotsim.so _robotsim.dll



